﻿@using CleanArchitecture.Core.Helper
@using CleanArchitecture.Infrastructure.Models.AdminUsers
@model AdminRoleSearchModel
@{
    Layout = "_BackendLayout";
    ViewData["Title"] = ViewBag.PageTitle as string;
    int currentSystemModuleId = ViewBag.CurrentSystemModuleId;
    var adminroleModel = Model.CustomProperties["adminroleModel"] as AdminRoleModel ?? null;
}
@section cssstyles {
    <style type="text/css">
        body {
            margin: 20px !important;
            display: flex;
            flex: auto;
            flex-direction: column;
            min-height: 0;
            background: #f0f2f5;
        }

        .adminrolemanage {
            width: 100% !important;
            height: 100%;
            background-color: #fff;
            margin: 0 !important;
            padding: 10px 2px;
        }
    </style>
}
<div class="adminrolemanage layui-main">
    <form class="layui-form">
        <fieldset class="layui-elem-field">
            <div class="layui-field-box pagebuttongroup">
                @await Component.InvokeAsync("PageButton")
            </div>
        </fieldset>

        <table id="adminrolemanagetable" lay-filter="adminrolemanagetable"></table>
    </form>
</div>
<input type="text" class="layui-hide" id="currentSystemModuleId" value="@currentSystemModuleId" />
@await Component.InvokeAsync("RecordButton")
<script type="text/html" id="isActiveTpl">
    <input type="checkbox" value="{{d.IsActive}}" lay-skin="switch" lay-text="正常|锁定" {{ d.IsActive ? 'checked' : '' }}>
</script>
@section scripts{
    <script type="text/javascript">
    var adminroletableconfig = {
        elem: "#adminrolemanagetable",
        url: '/api/backend/account/getadminroles',
        request: {
            pageName: '@Model.nameof(p => p.Page)', //页码的参数名称，默认：page
            limitName: '@Model.nameof(p => p.PageSize)' //每页数据量的参数名，默认：limit
        },
        method: 'post',
        contentType: 'application/json;charset=UTF-8',
        limits: [@Model.AvailablePageSizes],
        limit: @Model.PageSize,
        cols: [[
            //{ type: "checkbox", width: 50, fixed: "left" },
            { field: 'Id', title: 'ID', width: 50, align: "center" },
            { field: '@adminroleModel.nameof(p => p.OranizeName)', title: '@(ReflectionExtensions.GetPropertyDisplayName<AdminRoleModel>(m => m.OranizeName))'},
            { field: '@adminroleModel.nameof(p => p.RoleName)', title: '@(ReflectionExtensions.GetPropertyDisplayName<AdminRoleModel>(m => m.RoleName))'},
            {
                field: '@adminroleModel.nameof(p => p.IsAdmin)', title: '@(ReflectionExtensions.GetPropertyDisplayName<AdminRoleModel>(m => m.IsAdmin))',
                templet: function (d) {
                    if (d.IsAdmin) return '<span class="layui-badge-dot toolgroup" data-tips="系统管理员"></span>';
                    else return "";
                }
            },
            { field: '@adminroleModel.nameof(p => p.IsActive)', title: '@(ReflectionExtensions.GetPropertyDisplayName<AdminRoleModel>(m => m.IsActive))', width: 150, templet: '#isActiveTpl' },
            { title: '操作', minWidth: 100, templet: '#tableitemBars',fixed: "right", align: "center" }
        ]],
        parseData: function (res) {
            return {
                "code": res.state == 200 ? 0 : -1,     //解析接口状态
                "msg": res.message,     //解析提示文本
                "count": res.data.length, //解析数据长度
                "data": res.data   //解析数据列表
            };
        }
    };
    </script>
    <script src="~/js/backend/adminusermanage/adminrolemanage.min.js" charset="utf-8" asp-append-version="true"></script>
}
